package org.dawfinn.droiditarian.view;

import org.dawfinn.droiditarian.R;
import org.dawfinn.droiditarian.data.Deed;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DeedView extends LinearLayout {

	private Deed deed;
	private TextView deedTitle;
	private StatusIcon favorite;
	private StatusIcon completed;

	public DeedView(Context context, Deed deed) {
		super(context);

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.deed_view, this, true);

		deedTitle = (TextView) findViewById(R.id.name);
		favorite = (StatusIcon) findViewById(R.id.favorite);
		favorite.setUseAnimations(false);
		completed = (StatusIcon) findViewById(R.id.completed);
		completed.setUseAnimations(false);

		setDeed(deed);
	}

	public void setDeed(Deed deed) {
		this.deed = deed;
		deedTitle.setText(this.deed.getName());
		favorite.setChecked(deed.isFavorite());
		completed.setChecked(deed.isCompleted());
	}

	public Deed getDeed() {
		return deed;
	}
}
